package com.hundsun.finance.service;

import org.springframework.stereotype.Service;
import org.tinygroup.tinyscript.tree.impl.TreeDataNode;

import com.hundsun.finance.script.TinyScriptRunner;

@Service("saleService")
public class SaleServiceImpl extends TinyScriptRunner implements SaleService{

	public TreeDataNode insertCustomer(String customerName, String company,
			String city, String area) throws Exception {
		TreeDataNode dataNode = (TreeDataNode) getScriptEngine().execute("SaleService", "insertCustomer", customerName,company,city,area);
		return dataNode;
	}

	public TreeDataNode updateCustomer(String customerId, String customerName,
			String company, String city, String area) throws Exception {
		TreeDataNode dataNode = (TreeDataNode) getScriptEngine().execute("SaleService", "updateCustomer", customerId,customerName,company,city,area);
		return dataNode;
	}

	public TreeDataNode deleteCustomer(String customerId) throws Exception {
		TreeDataNode dataNode = (TreeDataNode) getScriptEngine().execute("SaleService", "deleteCustomer", customerId);
		return dataNode;
	}

	public TreeDataNode getCustomer(String customerId) throws Exception {
		TreeDataNode dataNode = (TreeDataNode) getScriptEngine().execute("SaleService", "getCustomer", customerId);
		return dataNode;
	}

	public TreeDataNode getCustomers() throws Exception {
		TreeDataNode dataNode = (TreeDataNode) getScriptEngine().execute("SaleService", "getCustomers");
		return dataNode;
	}

	public TreeDataNode insertContract(String customerId, Double amount,
			String sellDate) throws Exception {
		TreeDataNode dataNode = (TreeDataNode) getScriptEngine().execute("SaleService", "insertContract", customerId,amount,sellDate);
		return dataNode;
	}

	public TreeDataNode updateContract(String contractId, String customerId,
			Double amount, String sellDate) throws Exception {
		TreeDataNode dataNode = (TreeDataNode) getScriptEngine().execute("SaleService", "updateContract", contractId,customerId,amount,sellDate);
		return dataNode;
	}

	public TreeDataNode deleteContract(String contractId) throws Exception {
		TreeDataNode dataNode = (TreeDataNode) getScriptEngine().execute("SaleService", "deleteContract", contractId);
		return dataNode;
	}

	public TreeDataNode getContract(String contractId) throws Exception {
		TreeDataNode dataNode = (TreeDataNode) getScriptEngine().execute("SaleService", "getContract", contractId);
		return dataNode;
	}

	public TreeDataNode getContracts() throws Exception {
		TreeDataNode dataNode = (TreeDataNode) getScriptEngine().execute("SaleService", "getContracts");
		return dataNode;
	}

	public TreeDataNode countVip(String year, Double rate) throws Exception {
		TreeDataNode dataNode = (TreeDataNode) getScriptEngine().execute("SaleService", "countVip",year,rate);
		return dataNode;
	}

}
